package com.gupaoedu.starter;

import com.gupaoedu.starter.autoconfiguration.HelloProperties;
import com.gupaoedu.starter.format.FormatProcessor;

/**
 *  模板方法：类似的也有很多，像jdbcTemplate
 *
 *
 */
public class HelloFormatTemplate {

    private FormatProcessor formatProcessor;
    private HelloProperties helloProperties;

    public HelloFormatTemplate(FormatProcessor formatProcessor, HelloProperties helloProperties) {
        this.formatProcessor = formatProcessor;
        this.helloProperties = helloProperties;
    }

    public <T> String doFormat(T obj){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("Begin,Execute Format:").append("<br/>");
        stringBuilder.append("Hello Properties:").append(formatProcessor.format(helloProperties.getInfo())).append("<br/>");
        stringBuilder.append("Obj format result：").append(formatProcessor.format(obj)).append("<br/>");
        return stringBuilder.toString();
    }

}
